package com.gxa.customer.security.security.handler;

import com.gxa.common.utils.EncryptUtil;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

@Component
public class MyPasswordEncoder implements PasswordEncoder {

    //自定义密码加密方式,进行MD5加密
    @Override
    public String encode(CharSequence charSequence) {
        return EncryptUtil.encodeUTF8StringBase64(charSequence.toString());
    }
    //自定义密码解密方式,进行密码比对
    @Override
    public boolean matches(CharSequence charSequence, String s) {
        //进行客户端密码和与数据库密码进行比较
        //System.out.println(EncryptUtil.encodeUTF8StringBase64(charSequence.toString()));
        return s.equals(EncryptUtil.encodeUTF8StringBase64(charSequence.toString()));
    }
}
